//统一管理项目全部接口的文件
import request from './request'
import mockRequest from './mockRequest'
import {ListParamsType, LoginDataType, RegisterDataType, SubmitOrderDataType} from './types'

//三级联动的接口
export const reqGetCategoryList = () => request.get('/product/getBaseCategoryList')
//获取banner（Home首页轮播图接口）
export const reqGetBannerList = () => mockRequest.get('/banner')
//获取floor数据
export const reqGetFloorList = () => mockRequest.get('/floor')
//获取搜索模块数据  当前这个接口需要接受外部传参，给服务器传递一个默认参数（至少是一个空对象）
export const reqGetSearchInfo = (params: ListParamsType) => request.post('/list', params)
//获取产品详情信息的接口
export const reqGoodsInfo = (skuId: string) => request.get(`/item/${skuId}`)
//将产品添加到购物车中（获取更新某一个产品的个数）
export const reqAddOrUpdateShopCart = (skuId: string, skuNum: string) =>
    request.post(`/cart/addToCart/${skuId}/${skuNum}`)
//获取购物车列表数据接口
export const reqCartList = () => request.get('/cart/cartList')
//删除购物产品的接口
export const reqDelCartById = (skuId: string) => request.delete(`/cart/deleteCart/${skuId}`)
//修改商品的选中状态
export const reqUpdateChekedById = (skuId: string, isChecked: string) =>
    request.get(`/cart/checkCart/${skuId}/${isChecked}`)

//获取验证码
export const reqGetCode = (phone: string) => request.get(`/user/passport/sendCode/${phone}`)
//注册
export const reqUserRegister = (data: RegisterDataType) => request.post('/user/passport/register', data)
//登录
export const reqUserLogin = (data: LoginDataType) => request.post('/user/passport/login', data)
//获取用户信息【需要带着用户的token向服务器要用户信息】
export const reqUserInfo = () => request.get('/user/passport/auth/getUserInfo')
//退出登录
export const reqLogout = () => request.get('/user/passport/logout')

//获取用户地址信息
export const reqAddressInfo = () => request.get('/user/userAddress/auth/findUserAddressList')
//获取商品清单
export const reqOrderInfo = () => request.get('/order/auth/trade')
//提交订单的接口
export const reqSubmitOrder = (tradeNo: string, data: SubmitOrderDataType) =>
    request.post(`/order/auth/submitOrder?tradeNo=${tradeNo}`, data)
//获取支付信息
export const reqPayInfo = (orderId: string) => request.get(`/payment/weixin/createNative/${orderId}`)
//获取支付订单状态
export const reqPayStatus = (orderId: string) => request.get(`/payment/weixin/queryPayStatus/${orderId}`)
//获取我的订单列表
export const reqMyOrderList = (page: string, limit: string) => request.get(`/order/auth/${page}/${limit}`)
